import org.apache.spark.sql.functions.regexp_replace
val df = spark.createDataFrame(Seq(
(1, "1,3435"),
(2, "1,6566"),
(3, "-0,34435"))).toDF("Id", "x4")
df.withColumn("x4New", regexp_replace(df("x4"), "\\,", ".")).show
df.map(each => {
(each.getInt(0),each.getString(1).replace(",", "."))
})
.toDF("Id","x4")
.show
No comments:
Post a Comment